package com.ruoyi.project.bajiaostar.tUserAmount.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.bajiaostar.tUserAmount.domain.TUserAmount;
import com.ruoyi.project.bajiaostar.tUserAmount.service.ITUserAmountService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户账户Controller
 * 
 * @author wangwu
 * @date 2024-05-23
 */
@Controller
@RequestMapping("/bajiaostar/tUserAmount")
public class TUserAmountController extends BaseController
{
    private String prefix = "bajiaostar/tUserAmount";

    @Autowired
    private ITUserAmountService tUserAmountService;

    @RequiresPermissions("bajiaostar:tUserAmount:view")
    @GetMapping()
    public String tUserAmount()
    {
        return prefix + "/tUserAmount";
    }

    /**
     * 查询用户账户列表
     */
    @RequiresPermissions("bajiaostar:tUserAmount:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TUserAmount tUserAmount)
    {
        startPage();
        List<TUserAmount> list = tUserAmountService.selectTUserAmountList(tUserAmount);
        return getDataTable(list);
    }

    /**
     * 导出用户账户列表
     */
    @RequiresPermissions("bajiaostar:tUserAmount:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TUserAmount tUserAmount)
    {
        List<TUserAmount> list = tUserAmountService.selectTUserAmountList(tUserAmount);
        ExcelUtil<TUserAmount> util = new ExcelUtil<TUserAmount>(TUserAmount.class);
        return util.exportExcel(list, "tUserAmount",null);
    }

    /**
     * 新增用户账户
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用户账户
     */
    @RequiresPermissions("bajiaostar:tUserAmount:add")
    @Log(title = "用户账户", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TUserAmount tUserAmount)
    {
        return toAjax(tUserAmountService.insertTUserAmount(tUserAmount));
    }

    /**
     * 修改用户账户
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TUserAmount tUserAmount = tUserAmountService.selectTUserAmountById(id);
        mmap.put("tUserAmount", tUserAmount);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户账户
     */
    @RequiresPermissions("bajiaostar:tUserAmount:edit")
    @Log(title = "用户账户", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TUserAmount tUserAmount)
    {
        return toAjax(tUserAmountService.updateTUserAmount(tUserAmount));
    }

    /**
     * 删除用户账户
     */
    @RequiresPermissions("bajiaostar:tUserAmount:remove")
    @Log(title = "用户账户", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tUserAmountService.deleteTUserAmountByIds(ids));
    }
}
